package org.team4.web.ajax;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.team4.constants.StringConstant;
import org.team4.service.DictionaryService;

import com.opensymphony.xwork2.Action;

@Controller
@Scope("prototype")
public class DictionaryAjaxAction {
	
	@Autowired
	private DictionaryService dictionaryService;
	private String dictId;
	private String name;
	private String superId;
	private String state;
	
	/**
	 * 验证名称是否存在
	 * @return
	 * @throws Exception
	 */
	public String validateDictName() throws Exception {
		if(dictionaryService.nameExist(dictId, name, superId)) {
			state = StringConstant.FALSE;
		} else {
			state = StringConstant.TRUE;
		}
		return Action.SUCCESS;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setSuperId(String superId) {
		this.superId = superId;
	}

	public String getState() {
		return state;
	}

	public void setDictId(String dictId) {
		this.dictId = dictId;
	}
	
}